const packageName = require('./package.json').name

module.exports = {
  webpack: (config) => {
    config.output.library = packageName
    config.output.libraryTarget = 'umd'
    return config
  },
  devServer: function (configFunction) {
    return function (proxy, allowedHost) {
      const config = {
        ...configFunction(proxy, allowedHost),
        headers: {
          "Access-Control-Allow-Origin": "*"
        },
        proxy: {
          "/api": {
            target: 'http://localhost:3001',
            changeOrigin: true,
            pathRewrite: {
              "^/api": "/api"
            }
          }
        }
      }
      return config
    }
  }
}